//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader:'',//{ template: "<div>扩展组xx件</div>" },
        gridBody: '',
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: {view: [], box:[],  detail:[]},//扩展的按钮
    methods: {//事件扩展
        getFormOption(field) {
            let option;
            this.editFormOptions.forEach(x => {
                x.forEach(item => {
                    if (item.field == field) {
                        option = item;
                    }
                })
            })
            return option;
            },
        
       onInit() {
        this.maxBtnLength = 5;
        this.boxOptions.height = document.documentElement.clientHeight * 0.5;
        this.columns.push({
            title: '操作',
            fixed: 'right',
            width: 140,
            render: (h, { row, column, index }) => {
                return h(
                    "div", { style: {} }, [
                        h(
                            "a", {
                                props: {},
                                style: {},
                                on: {
                                    click: (e) => {
                                        //this.$Message.info(row.accountsReceivable);
                                        // e.stopPropagation()
                                        //console.log(this.$refs.gridHeader)
                                        this.linkData(row);
                                    }
                                }
                            },
                            "编辑"
                        ),
                        
                    ])
            }
        })
         
       
            this.$store.getters.data().reportPrice = this;
            this.editFormFileds.carousel_name = [];
            var selectOption = this.getFormOption('carousel_name');
            selectOption.type = "cascader";
            selectOption.changeOnSelect = false;
            //初始一个空的数据源(必须)
            selectOption.data=[];
            selectOption.onChange = (val, item) => {  
            let productname="";
            let prodctcode="";
            for(let i=item.length-1;i>=0;i--){
            if(i==item.length-1){productname+=item[i].label;prodctcode+=item[i].value};
            //if(i==0){productname+=item[i].label;prodctcode+=item[i].value};
            }
            if(this.editFormFileds.carousel_name==''){
            this.editFormFileds.carousel_name=productname;
            this.editFormFileds.productID=prodctcode;
            }
            this.getcolumn(val);
            this.$set(selectOption, "disabled", true);
        }
        
       },
       
       modelOpenBefore(){
        var selectOption = this.getFormOption('carousel_name');
        selectOption.data=[];
          //从后台接口返回数据源,格式见iview组件result(建议在modelOpenBefore方法中设置数据源)
            this.http.post("api/producttypes/GetProtypeList").then(result=>{
              result.result.forEach(item=>{
                  selectOption.data.push(item)
              })
          })
      },
   
   rowClick({ row, column, event }) { //查询界面table点击行选中当前行
    //console.log(row,column,event);
   
    this.$refs.table.$refs.table.toggleRowSelection(row);
    
    return true;
   },
   modelOpenAfter() {
    let isEDIT = this.currentAction == this.const.EDIT;
    this.editFormOptions.forEach(item => {
        item.forEach(x => {
                if(x.field == "carousel_name"){
                    this.$set(x, "disabled", isEDIT)
                }
            })
    })
    // var selectOption = this.getFormOption('carousel_name');  
    //     if(!isEDIT) {
    //         selectOption.onInput = (val) => {    
    //         this.editFormFields.productID=this.base.chineseToPinYin(val);
    //         }
    //     } 
        // var Code = this.getFormOption('productID');
        // this.$set(Code, "disabled", true)
       
   }
},
    
    
};
export default extension;